Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.2.0] Silence setlocale warnings in Java stub #17741

Merged
merged 1 commit into from
Mar 11, 2023

Conversation

ShreeM01
Copy link
Contributor

Since 17cfa01, the java_stub_template.txt file calls into the locale tool to check for the presence of cetain locales. These calls correctly send error messages to stderr.

Unfortunately, bash itself is doing locale lookups as soon as it sees that the LANG or LC_* variables are touched, and this results in warnings that pollute the output. In our builds, the output is polluted with hundreds of warnings like these:

bazel-out/aarch64-opt-exec-CF41B97/bin/external/bfg/lang/java/src/main/java/com/google/devtools/build/bfg/JavaSourceFileParserCli: line 100: warning: setlocale: LC_CTYPE: cannot change locale (): No such file or directory
bazel-out/aarch64-opt-exec-CF41B97/bin/external/bfg/lang/java/src/main/java/com/google/devtools/build/bfg/JavaSourceFileParserCli: line 102: warning: setlocale: LC_CTYPE: cannot change locale (): No such file or directory

There is nothing we can do to avoid these warnings. Trying to set the LANG or LC_* variables via --action_env and --host_action_env has no effect (other than trigger more/different warnings).

The problem stems from https://bugzilla.redhat.com/show_bug.cgi?id=1361965, which has been fixed in various distros but hasn't made its way to the one we are currently using.

Given that it's bash that is complaining, we can easily side-step this issue by patching the template and wrapping the problematic invocations behind "env". In this way, bash never gets to see the locale changes. This change does precisely this.

Closes #17670.

PiperOrigin-RevId: 515350095
Change-Id: I1887003802aa329e7fb96f644a2fba906daf5165

Since 17cfa01, the java_stub_template.txt file calls into the locale tool to check for the presence of cetain locales.  These calls correctly send error messages to stderr.

Unfortunately, *bash* itself is doing locale lookups as soon as it sees that the LANG or LC_* variables are touched, and this results in warnings that pollute the output.  In our builds, the output is polluted with hundreds of warnings like these:

```
bazel-out/aarch64-opt-exec-CF41B97/bin/external/bfg/lang/java/src/main/java/com/google/devtools/build/bfg/JavaSourceFileParserCli: line 100: warning: setlocale: LC_CTYPE: cannot change locale (): No such file or directory
bazel-out/aarch64-opt-exec-CF41B97/bin/external/bfg/lang/java/src/main/java/com/google/devtools/build/bfg/JavaSourceFileParserCli: line 102: warning: setlocale: LC_CTYPE: cannot change locale (): No such file or directory
```

There is nothing we can do to avoid these warnings.  Trying to set the LANG or LC_* variables via --action_env and --host_action_env has no effect (other than trigger more/different warnings).

The problem stems from https://bugzilla.redhat.com/show_bug.cgi?id=1361965, which has been fixed in various distros but hasn't made its way to the one we are currently using.

Given that it's bash that is complaining, we can easily side-step this issue by patching the template and wrapping the problematic invocations behind "env".  In this way, bash never gets to see the locale changes. This change does precisely this.

Closes bazelbuild#17670.

PiperOrigin-RevId: 515350095
Change-Id: I1887003802aa329e7fb96f644a2fba906daf5165
@ShreeM01 ShreeM01 merged commit db5c9ec into bazelbuild:release-6.2.0 Mar 11, 2023
@keertk keertk added the team-Rules-Java Issues for Java rules label Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants